<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<title>Catalog</title>
</head>
<body>
<body background="../img/bg.jpg"> 
	<font face="Berlin Sans FB Demi" color="#357EC7" size="3">
<center>
<br><br><br><br>
<h1>Adauga note</h1>
	<?
error_reporting (E_ALL ^ E_NOTICE);
include('auth.php');
include('../config.php');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {die('Failed to connect to server: ' . mysql_error());}
           
$db = mysql_select_db(DB_DATABASE);
if(!$db) {die("Unable to select database");}
?>
<b>

<form action='' method="post">
<table border="1">
<tr><td>Elev: </td><td><b><? $elev=$_GET['elev']; $r=mysql_fetch_array(mysql_query("select nume from elev where id='".$elev."'")); echo $r[0]; ?></b></td></tr>
<tr><td>Materie: </td><td><b><? $materie=$_GET['materie']; $r=mysql_fetch_array(mysql_query("select nume from materie where id='".$materie."'")); echo $r[0];?></b></td></tr>
<tr><td>Nota: </td><td><input type="text" name="nota"></td></tr>
<input type="hidden" value="<? echo $elev; ?>" name="elev">
<input type="hidden" value="<? echo $materie; ?>" name="materie">
<tr><td colspan="2"><center><input type="submit" name="addabs" value="OK"></center></tr></td>
</form>
<?
function clean($str) {
		$str = @trim($str);
		if(get_magic_quotes_gpc()) {
			$str = stripslashes($str);
		}
		return mysql_real_escape_string($str);
	}
;
$nota=clean($_POST['nota']);


$s=explode('/',$nota);

if ($nota!='') {
$sql=mysql_query("insert into note(elev_id,materie_id,nota,sem) values ('".$_GET['elev']."','".$_GET['materie']."','".$nota."','".$_GET['sem']."')");
if ($nota<=5) {
$email=mysql_fetch_array(mysql_query("select * from elev where nume='".$_GET['nume']."'"));
mail($email['email_parinte'],'Nota mica',"Copilul dvs,".$_POST['elev'].", a obtinut nota ".$s[0]." la materia ".$_POST['materie']." in data de ".$s[1]."",'From: fast_michael98@yahoo.com');
}
unset($_SESSION['elev']);
	unset($_SESSION['materie']);
header('location: clasa.php');
}


?>
</font>
</center>
</body>
</html>